package com.hoshiicloud.common.query;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;

/**
 * <p> 查询条件工具类 </p>
 *
 * @author Tortoise
 * @since 2018-08-27
 */
@Slf4j
public abstract class QueryUtils {

    /**
     * 分页参数转换分页对象
     *
     * @param <T>       泛型
     * @return 分页对象
     */
    public static <T> IPage<T> toPage(T t) {
        PageParam commonParam = (PageParam) t;

        Page<T> page = new Page<>();

        page.setCurrent(Long.parseLong(commonParam.getPageNumber()));
        page.setSize(Long.parseLong(commonParam.getPageSize()));

        return page;
    }




}
